<body>
<p>Test some cases of MessagePort garbage collection.</p>
<pre id=log></pre>
<script src="../../resources/gc.js"></script>
<script>

function log(message)
{
    document.getElementById("log").innerHTML += message + "<br>";
}

function done()
{
    channel.port1.close();
    channel.port2.close();

    gc();

    log("DONE");
    if (window.testRunner)
        testRunner.notifyDone();
}

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

var channel = new MessageChannel;
channel.port1.foo = "bar";

gc();
log("Should be 'bar': " + channel.port1.foo);

channel.port1.onmessage = function() { log("onmessage"); }
channel.port1.addEventListener("message", function() { log("message listener"); done(); }, false);

gc();
channel.port1.start();
channel.port2.postMessage("msg");

gc();

</script>
</body>
